//
//  XMAccountSafeViewController.m
//  XMJJ_zml
//
//  Created by 丁浩 on 2025/5/21.
//

#import "XMAccountSafeViewController.h"
#import "XMAccountSafeView.h"
#import "XMChangeMobileViewController.h"
#import "XMQRCodeViewController.h"
#import "XMRealNameAuthenViewController.h"
#import "XMPWSetViewController.h"
#import "XMNetwork+mine.h"

@interface XMAccountSafeViewController ()

@property (nonatomic, strong) XMAccountSafeView *accountSafeView;

@end

@implementation XMAccountSafeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatUI];
}

- (void)creatUI {
    [self.view addSubview:self.accountSafeView];
    [_accountSafeView setContentWithUserInfoModel:self.userInfoModel];
}

- (void)cancelAccount {
    XMWeakSelf;
    [_Network cancelAccountSuccess:^(id  _Nonnull responseObject) {
        [[XMUserManager shareInstance] removeUser];
        [weakSelf.navigationController popToRootViewControllerAnimated:NO];
        self.tabBarController.selectedIndex = 0;
    } failure:^(NSError * _Nonnull error) {
        
    }];
//    [_Network logoutSuccess:^(id  _Nonnull responseObject) {
//        [[XMUserManager shareInstance] removeUser];
//        [[XMUserManager shareInstance] removeToken];
//    } failure:^(NSError * _Nonnull error) {
//
//    }]
}

- (void)itemSelectWithSection:(NSInteger)section row:(NSInteger)row {
    if (section == 0) {
        switch (row) {
            case 0: {
                
            }
                break;
            case 1: {
                
            }
                break;
            case 2: {
                XMQRCodeViewController *qrcodeVC = [[XMQRCodeViewController alloc] init];
                qrcodeVC.userInfoModel = self.userInfoModel;
                [self.navigationController pushViewController:qrcodeVC animated:YES];
            }
                break;
            case 3: {
                XMChangeMobileViewController *changeMobileVC = [[XMChangeMobileViewController alloc] init];
                [self.navigationController pushViewController:changeMobileVC animated:YES];
            }
                break;
            case 4: {
                XMPWSetViewController *pwSetVC = [[XMPWSetViewController alloc] init];
                [self.navigationController pushViewController:pwSetVC animated:YES];
            }
                break;
            case 5: {
                XMRealNameAuthenViewController *realNameVC = [[XMRealNameAuthenViewController alloc] init];
                realNameVC.userInfoModel = _userInfoModel;
                [self.navigationController pushViewController:realNameVC animated:YES];
            }
                break;
                
            default:
                break;
        }
    }
    else {
        switch (row) {
            case 0: {
                
            }
                break;
            case 1: {
                
            }
                break;
            case 2: {
                
            }
                break;
                
            default:
                break;
        }
    }
}


- (XMAccountSafeView *)accountSafeView {
    if (!_accountSafeView) {
        _accountSafeView = [[XMAccountSafeView alloc] initWithFrame:self.view.bounds];
        XMWeakSelf;
        _accountSafeView.itemSelectBlock = ^(NSInteger indexSection, NSInteger indexRow) {
            [weakSelf itemSelectWithSection:indexSection row:indexRow];
        };
        _accountSafeView.cancelAccountBlock = ^{
            
        };
    }
    return _accountSafeView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
